home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Developer Essentials / MPW Interfaces & Libraries / CIncludes / Connections.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-29  |  7.7 KB  |  285 lines  |  [TEXT/MPS ]

  1.  
  2. /************************************************************
  3.  
  4. Created: Wednesday, September 11, 1991 at 11:31 AM
  5.  Connections.h
  6.  C Interface to the Macintosh Libraries
  7.  
  8.  
  9.   Copyright Apple Computer, Inc. 1988-1991
  10.   All rights reserved
  11.  
  12. ************************************************************/
  13.  
  14.  
  15. #ifndef __CONNECTIONS__
  16. #define __CONNECTIONS__
  17.  
  18. #ifndef __DIALOGS__
  19. #include <Dialogs.h>
  20. #endif
  21.  
  22. #ifndef __CTBUTILITIES__
  23. #include <CTBUtilities.h>
  24. #endif
  25.  
  26.  
  27. enum {
  28.  
  29.  
  30. /*    current Connection Manager version    */
  31.  curCMVersion = 2,
  32.  
  33. /*    current Connection Manager Environment Record version     */
  34.  curConnEnvRecVers = 0,
  35.  
  36. /* CMErr */
  37.  cmGenericError = -1,
  38.  cmNoErr = 0,
  39.  cmRejected = 1,
  40.  cmFailed = 2,
  41.  cmTimeOut = 3,
  42.  cmNotOpen = 4,
  43.  cmNotClosed = 5,
  44.  cmNoRequestPending = 6,
  45.  cmNotSupported = 7,
  46.  cmNoTools = 8,
  47.  cmUserCancel = 9,
  48.  cmUnknownError = 11
  49. };
  50.  
  51. typedef OSErr CMErr;
  52.  
  53. enum {
  54.   cmData    = 1 << 0,
  55.  cmCntl    = 1 << 1,
  56.  cmAttn    = 1 << 2,
  57.  cmDataNoTimeout = 1 << 4,
  58.  cmCntlNoTimeout = 1 << 5,
  59.  cmAttnNoTimeout = 1 << 6,
  60.  cmDataClean  = 1 << 8,  
  61.  cmCntlClean  = 1 << 9,
  62.  cmAttnClean  = 1 << 10,
  63. /*  Only for CMRecFlags (not CMChannel) in the rest of this enum */
  64.  cmNoMenus   = 1 << 16, 
  65.  cmQuiet   = 1 << 17,
  66.  cmConfigChanged   = 1 << 18
  67. };
  68.  
  69. /* CMRecFlags and CMChannel  */
  70. /*  Low word of CMRecFlags is same as CMChannel */
  71. typedef long CMRecFlags;
  72.  
  73.  
  74. typedef short CMChannel;
  75.  
  76. enum {
  77.  cmStatusOpening = 1 << 0,
  78.  cmStatusOpen = 1 << 1,
  79.  cmStatusClosing = 1 << 2,
  80.  cmStatusDataAvail  = 1 << 3,
  81.  cmStatusCntlAvail  = 1 << 4,
  82.  cmStatusAttnAvail  = 1 << 5,
  83.  
  84.  cmStatusDRPend   = 1 << 6,     /* data read pending */
  85.  cmStatusDWPend   = 1 << 7,     /* data write pending */
  86.  cmStatusCRPend   = 1 << 8,     /* cntl read pending */
  87.  cmStatusCWPend   = 1 << 9,     /* cntl write pending */
  88.  cmStatusARPend   = 1 << 10,     /* attn read pending */
  89.  cmStatusAWPend   = 1 << 11,     /* attn write pending */
  90.  
  91.  cmStatusBreakPend  = 1 << 12,
  92.  cmStatusListenPend  = 1 << 13,
  93.  cmStatusIncomingCallPresent = 1 << 14,
  94.  
  95.  cmStatusReserved0 = 1 << 15
  96. };
  97. typedef unsigned long CMStatFlags;
  98.  
  99. enum {cmDataIn,cmDataOut,cmCntlIn,cmCntlOut,cmAttnIn,cmAttnOut,cmRsrvIn,
  100.  cmRsrvOut};
  101. typedef unsigned short CMBufFields;
  102.  
  103.  
  104. typedef Ptr CMBuffers[8];
  105. typedef long CMBufferSizes[8];
  106. typedef const long *ConstCMBufferSizesParam;
  107.  
  108. enum {cmSearchSevenBit = 1 << 0};
  109. typedef unsigned short CMSearchFlags;
  110.  
  111. enum {cmFlagsEOM  = 1 << 0};
  112. typedef unsigned short CMFlags;
  113.  
  114.  
  115. struct ConnEnvironRec {
  116.  short version;
  117.  long baudRate;
  118.  short dataBits;
  119.  CMChannel channels;
  120.  Boolean swFlowControl;
  121.  Boolean hwFlowControl;
  122.  CMFlags flags;
  123. };
  124.  
  125. typedef struct ConnEnvironRec ConnEnvironRec;
  126. typedef ConnEnvironRec *ConnEnvironRecPtr;
  127.  
  128. struct ConnRecord {
  129.  short procID;
  130.  CMRecFlags flags;
  131.  CMErr errCode;
  132.  long refCon;
  133.  long userData;
  134.  ProcPtr defProc;
  135.  Ptr config;
  136.  Ptr oldConfig;
  137.  long asyncEOM;
  138.  long reserved1;
  139.  long reserved2;
  140.  Ptr cmPrivate;
  141.  CMBuffers bufferArray;
  142.  CMBufferSizes bufSizes;
  143.  long mluField;
  144.  CMBufferSizes asyncCount;
  145. };
  146.  
  147. typedef struct ConnRecord ConnRecord;
  148. typedef ConnRecord *ConnPtr, **ConnHandle;
  149.  
  150.  
  151. /* application routines type definitions */
  152. typedef pascal void  (*ConnectionSearchCallBackProcPtr) (ConnHandle hConn, Ptr matchPtr, long refNum);
  153. typedef pascal void  (*ConnectionCompletionProcPtr) (ConnHandle hConn);
  154. typedef pascal void  (*ConnectionChooseIdleProcPtr) (void);
  155.  
  156. enum {
  157.  
  158.  
  159. /* CMIOPB constants and structure */
  160.  cmIOPBQType = 10,
  161.  cmIOPBversion = 0
  162. };
  163.  
  164. struct CMIOPB {
  165.  QElemPtr qLink;
  166.  short qType;                    /* cmIOPBQType */
  167.  ConnHandle hConn;
  168.  Ptr theBuffer;
  169.  long count;
  170.  CMFlags flags;
  171.  ConnectionCompletionProcPtr userCompletion;
  172.  long timeout;
  173.  CMErr errCode;
  174.  CMChannel channel;
  175.  long asyncEOM;
  176.  long reserved1;
  177.  short reserved2;
  178.  short version;                    /* cmIOPBversion */
  179.  long refCon;                    /* for application */
  180.  long toolData1;                /* for tool */
  181.  long toolData2;                /* for tool */
  182. };
  183.  
  184. typedef struct CMIOPB CMIOPB;
  185. typedef CMIOPB *CMIOPBPtr;
  186.  
  187.  
  188. #ifdef __cplusplus
  189. extern "C" {
  190. #endif
  191. pascal CMErr InitCM(void); 
  192. pascal Handle CMGetVersion(ConnHandle hConn); 
  193. pascal short CMGetCMVersion(void); 
  194.  
  195. pascal ConnHandle CMNew(short procID,CMRecFlags flags,ConstCMBufferSizesParam desiredSizes,
  196.  long refCon,long userData); 
  197.  
  198. pascal void CMDispose(ConnHandle hConn); 
  199.  
  200. pascal CMErr CMListen(ConnHandle hConn,Boolean async,ConnectionCompletionProcPtr completor,
  201.  long timeout); 
  202. pascal CMErr CMAccept(ConnHandle hConn,Boolean accept); 
  203.  
  204. pascal CMErr CMOpen(ConnHandle hConn,Boolean async,ConnectionCompletionProcPtr completor,
  205.  long timeout); 
  206. pascal CMErr CMClose(ConnHandle hConn,Boolean async,ConnectionCompletionProcPtr completor,
  207.  long timeout,Boolean now); 
  208.  
  209. pascal CMErr CMAbort(ConnHandle hConn); 
  210.  
  211. pascal CMErr CMStatus(ConnHandle hConn,CMBufferSizes sizes,CMStatFlags *flags); 
  212. pascal void CMIdle(ConnHandle hConn); 
  213.  
  214. pascal void CMReset(ConnHandle hConn); 
  215.  
  216. pascal void CMBreak(ConnHandle hConn,long duration,Boolean async,ConnectionCompletionProcPtr completor); 
  217.  
  218. pascal CMErr CMRead(ConnHandle hConn,void *theBuffer,long *toRead,CMChannel theChannel,
  219.  Boolean async,ConnectionCompletionProcPtr completor,long timeout,CMFlags *flags); 
  220. pascal CMErr CMWrite(ConnHandle hConn,const void *theBuffer,long *toWrite,
  221.  CMChannel theChannel,Boolean async,ConnectionCompletionProcPtr completor,
  222.  long timeout,CMFlags flags); 
  223.  
  224. pascal CMErr CMIOKill(ConnHandle hConn,short which); 
  225.  
  226. pascal void CMActivate(ConnHandle hConn,Boolean activate); 
  227. pascal void CMResume(ConnHandle hConn,Boolean resume); 
  228. pascal Boolean CMMenu(ConnHandle hConn,short menuID,short item); 
  229.  
  230. pascal Boolean CMValidate(ConnHandle hConn); 
  231. pascal void CMDefault(Ptr *theConfig,short procID,Boolean allocate); 
  232.  
  233. pascal Handle CMSetupPreflight(short procID,long *magicCookie); 
  234. pascal Boolean CMSetupFilter(short procID,const void *theConfig,short count,
  235.  DialogPtr theDialog,EventRecord *theEvent,short *theItem,long *magicCookie); 
  236. pascal void CMSetupSetup(short procID,const void *theConfig,short count,
  237.  DialogPtr theDialog,long *magicCookie); 
  238. pascal void CMSetupItem(short procID,const void *theConfig,short count,
  239.  DialogPtr theDialog,short *theItem,long *magicCookie); 
  240. pascal void CMSetupXCleanup(short procID,const void *theConfig,short count,
  241.  DialogPtr theDialog,Boolean OKed,long *magicCookie); 
  242. pascal void CMSetupPostflight(short procID); 
  243.  
  244. pascal Ptr CMGetConfig(ConnHandle hConn); 
  245. pascal short CMSetConfig(ConnHandle hConn,const void *thePtr); 
  246.  
  247. pascal OSErr CMIntlToEnglish(ConnHandle hConn,const void *inputPtr,Ptr *outputPtr,
  248.  short language); 
  249. pascal OSErr CMEnglishToIntl(ConnHandle hConn,const void *inputPtr,Ptr *outputPtr,
  250.  short language); 
  251.  
  252. pascal long CMAddSearch(ConnHandle hConn,ConstStr255Param theString,CMSearchFlags flags,
  253.  ConnectionSearchCallBackProcPtr callBack); 
  254. pascal void CMRemoveSearch(ConnHandle hConn,long refnum); 
  255. pascal void CMClearSearch(ConnHandle hConn); 
  256.  
  257. pascal CMErr CMGetConnEnvirons(ConnHandle hConn,ConnEnvironRec *theEnvirons); 
  258.  
  259. pascal short CMChoose(ConnHandle *hConn,Point where,ConnectionChooseIdleProcPtr idleProc); 
  260.  
  261. pascal void CMEvent(ConnHandle hConn,const EventRecord *theEvent); 
  262.  
  263. pascal void CMGetToolName(short procID,Str255 name); 
  264. pascal short CMGetProcID(ConstStr255Param name); 
  265.  
  266. pascal void CMSetRefCon(ConnHandle hConn,long refCon); 
  267. pascal long CMGetRefCon(ConnHandle hConn); 
  268.  
  269. pascal long CMGetUserData(ConnHandle hConn); 
  270. pascal void CMSetUserData(ConnHandle hConn,long userData); 
  271.  
  272. pascal void CMGetErrorString(ConnHandle hConn,short id,Str255 errMsg); 
  273.  
  274. pascal CMErr CMNewIOPB(ConnHandle hConn,CMIOPBPtr *theIOPB); 
  275. pascal CMErr CMDisposeIOPB(ConnHandle hConn,CMIOPBPtr theIOPB); 
  276.  
  277. pascal CMErr CMPBRead(ConnHandle hConn,CMIOPBPtr theIOPB,Boolean async); 
  278. pascal CMErr CMPBWrite(ConnHandle hConn,CMIOPBPtr theIOPB,Boolean async); 
  279. pascal CMErr CMPBIOKill(ConnHandle hConn,CMIOPBPtr theIOPB); 
  280. #ifdef __cplusplus
  281. }
  282. #endif
  283.  
  284. #endif
  285.